package com.tjnu.losca.config;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

/**
 * @author Losca
 * @date 2021/9/17 15:18
 */
@Component
public class UserInterceptor implements HandlerInterceptor {
    //@Override
    //public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
    //    System.out.println("拦截器");
    //    String token = request.getHeader("token");
    //    String method = request.getMethod();
    //    System.out.println(token);
    //    System.out.println(method);
    //    Teacher teacher = new Teacher();
    //    try {
    //        teacher = JWTUtil.decoder(token);
    //        return true;
    //    } catch (Exception e) {
    //        e.printStackTrace();
    //        //将信息转化为json给前段
    //        ResponseVO msg = ResponseVO.unAuthed("该请求不合法");
    //        response.setContentType("application/json;charset=utf-8");
    //        ObjectMapper objectMapper = new ObjectMapper();
    //        String s = objectMapper.writeValueAsString(msg);
    //        response.getWriter().write(s);
    //        return false;
    //    }
    //
    //}
}
